在瀏覽器與 node.js 運行 javascript


Posted by ericcch24 on 2020-06-22

瀏覽器

  • 用 git 建立一個 html 的檔案
  • vim 執行
  • 在 html 檔案中撰寫,並於兩個標籤間撰寫JavaScript程式碼。例如:
    <script>
    console.log("hello world")
    </script>
    
  • 存檔後用瀏覽器開啟此檔,F12 就看到上面程式碼的輸出結果

node.js

  • 用 git 建立一個 javascript 的檔案
  • 在裡面輸入
    console.log("hello world")
    
  • 在 git 輸入 node 檔名.js 即可輸出檔案的內容
    (或是直接在 git 輸入 node 也可以直接運行)

#WeeK2







Related Posts

C# class, object, method, constructors, getter, setter, static

C# class, object, method, constructors, getter, setter, static

[JS] 認識變數:let、const、var

[JS] 認識變數:let、const、var

layer-list 應用 - 愛奇藝和當貝市場的 QR Code 掃描外框

layer-list 應用 - 愛奇藝和當貝市場的 QR Code 掃描外框


Comments